package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/29 16:31
 **/
public class Day28_1_Op01_09_IsFlipedString {
    // 多次旋转
    class Solution {
        public boolean isFlipedString(String s1, String s2) {
            if(s1.length() != s2.length()) return false;
            int[] arr = new int[26];
            for(int i = 0; i < s1.length(); ++i){
                arr[s1.charAt(i)-'a']++;
                arr[s2.charAt(i)-'a']--;
            }
            for(int i : arr){
                if(i != 0) return false;
            }
            return true;
        }
    }
    class Solution2 {
        public boolean isFlipedString(String s1, String s2) {
            if(s1.length() != s2.length()) return false;
            if(s1.equals(s2)) return true;
            int n = s1.length();
            for(int i = 1; i < n; ++i){
                String l = s1.substring(0, i);
                String r = s1.substring(i, n);

                if(s2.equals(new StringBuffer(r + l).toString())){
                    return true;
                }
            }
            return false;
        }
    }
    class Solution3 {
        public boolean isFlipedString(String s1, String s2) {
            if(s1.length() != s2.length()) return false;
            String s3 = s2 + s2;
            return s3.contains(s1);
        }
    }
}